<?php

require_once ('LikeMVC/Controller/Router/Interface.php');

class LikeMVC_Controller_Router_Standard implements LikeMVC_Controller_Router_Interface {
	
	public function route($request) {
		$component = $request->getComponentName();
		$module = $request->getModuleName();
		
		require_once 'LikeMVC/Utils/Common.php';
		require_once 'LikeMVC/Registry/Directory.php';
		
		$component = LikeMVC_Utils_Common::convertNameToDirectory($component);
		$module .= "Module";
		$module = LikeMVC_Utils_Common::convertNameToClass($module);
		$modulefile = LikeMVC_Utils_Common::convertNameToClassFile($module);
		$compath = LikeMVC_Registry_Directory::getInstance()->getComponentDirectory($component);
		
		if ($compath == null)	{
			$compath = "application";
		}
		
		$modfile = $compath."/modules/".$modulefile;
		require_once 'LikeMVC/Loader/Loader.php';
		if (LikeMVC_Loader_Loader::isReadable($modfile))	{
			include $modfile;
			if (class_exists($module))	{
				$moduleObj = new $module;
				return $moduleObj;
			}
		}
		return null;
	}
}

?>